# Maintainer: Masanori Shirayama <mashir43@gmail.com>

pkgname=mksh
_ver=59
# use a pacman compatible version scheme
pkgver=${_ver/[a-z]/.${_ver//[0-9.]/}}
pkgrel=2
pkgdesc="The MirBSD Korn Shell"
arch=("i686" "x86_64")
url="https://www.mirbsd.org/mksh.htm"
license=('ISC')
depends=('gcc-libs')
makedepends=('gcc')
provides=('ksh')
conflicts=('ksh')
install=mksh.install
source=("https://www.mirbsd.org/MirOS/dist/mir/${pkgname}/${pkgname}-R${_ver}.tgz"
        "https://www.mirbsd.org/TaC-mksh.txt")
sha256sums=('592a28ba67bea8a285f003d7a5d21b65e718546c8fcb375d7d696f3d5dd390ba'
            '8a53fe4d643fb7341e6c94653d63d3d813d8d849fc1d9dfe5dc49ab2fb48aee9')

build() {
  cd "${srcdir}/${pkgname}"

  ./Build.sh
}

check() {
  cd "${srcdir}/${pkgname}"
  ./test.sh
}

package() {
  cd "${srcdir}/${pkgname}"

  mkdir -p "${pkgdir}/usr/bin"
  mkdir -p "${pkgdir}/usr/share/man/man1"
  mkdir -p "${pkgdir}/usr/share/licenses/mksh"

  cp -f mksh.exe ${pkgdir}/usr/bin
  cp -f mksh.1 ${pkgdir}/usr/share/man/man1

  cd "${srcdir}"
  cp -f TaC-mksh.txt ${pkgdir}/usr/share/licenses/mksh

  cd "${pkgdir}/usr/bin"
  cp -f mksh.exe ksh.exe
}
